package tests;

import common.Utils;
import org.openqa.selenium.By;

public class ListPage extends Utils {
    public static String url = "http://8.156.68.126:8080/blog_list.html";

    public ListPage() {
        super(url);
    }

    /**
     * 博客列表页——三个模块（菜单模块、用户信息模块、博客列表模块）
     */
    //检查博客列表模块是否正确
    public void checkBlogList(){
        //检查博客标题
        String titleText = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > div.title")).getText();
        //检查博客时间
        String timeText = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > div.date")).getText();
        //检查博客内容
        String contentText = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > div.desc")).getText();
        //检查查看全文按钮
        String actualText = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > a")).getText();


        String expectText = "查看全文>>";
        //校验查看全文按钮
        assert actualText.equals(expectText);
        //校验标题、博客内容、时间不能为空
        assert !titleText.isEmpty();
        assert !timeText.isEmpty();
        assert !contentText.isEmpty();

        driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > a")).click();
        //跳转到博客详情---一定是有效的博客详情页
        DetailUrl = driver.getCurrentUrl();
    }
}
